package net.flyinggroup.jasypt.service;

import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

@Service
public class JasyptUsageService {
    @Value("${encrypted.property}")
    private String property;

    @Autowired
    private StringEncryptor encryptor;

    public String getProperty() {
        return property;
    }

    public String getPasswordUsingEnvironment(Environment environment) {
        System.out.println(encryptor.encrypt("Password"));
        return environment.getProperty("encrypted.property");
    }
}
